package top.huiwow.entity;

import com.c45y.Bastille.Entities.BastilleWither;
import com.c45y.Bastille.Entities.BastilleZombie;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import top.huiwow.GameCore;
import top.huiwow.listeners.EntityListener;
import top.huiwow.managers.GamePlayer;
import top.huiwow.utils.Validates;

import java.util.Collections;

public class Negromancer extends AkaishiEntity {
    int internalID;


    @NotNull
    @Override
    public Class<BastilleZombie> getEntityType() {
        return BastilleZombie.class;
    }

    @NotNull
    @Override
    public EntityStats getStats(int level) {
        double hp=level* (GameCore.getRandom().nextInt(99)+1);
        return new EntityStats(Collections.singletonList(new ItemStack(Material.GOLDEN_APPLE, 1)),hp , hp, "Negromancer Zombie", true);
    }

    @Override
    public int getInternalID() {
        return internalID;
    }

    @Override
    public void setInternalID(int i) {
        internalID = i;
    }
    @EventHandler
    public void onHit(EntityDamageByEntityEvent e) {
        GamePlayer damager = Validates.validateP(e);
        if (damager == null) {
            return;
        }
        if (EntityListener.isEntity(e.getEntity(), this.internalID)) {
            if (GameCore.getRandom().nextDouble() < 0.2) {
                GameCore.getInstance().getEntityManager().spawnEntity(e.getEntity().getLocation(),this.internalID,10);
            }

        }
    }

}